/*****************************************************************************
 * plum_hal_dio.h
 *
 * Copyright (C) 2020 Jeasonvor 1101627719@qq.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
#ifndef __PLUM_HAL_DIO_H__
#define __PLUM_HAL_DIO_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/*****************************************************************************
 * Public Types
 ****************************************************************************/

typedef struct {
    plum_u32 di_id;
    plum_u32 do_id;
    plum_u32 clk_id;
} dio_io_t;

typedef struct {
    dio_io_t io;

} plum_hal_dio_cof_t;

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  DIO接口初始化
 *
 * @param[in]:  id      -   接口plum ID
 * @param[in]:  cof     -   配置指针
 *
 * @return: 返回执行状态
 * **/
plum_s32 plum_hal_dio_init(plum_u32 id, plum_hal_dio_cof_t *cof);

/**
 * @brief:  通过DIO读一字节数据
 *
 * @param[in]:  id  -   端口plum ID
 *
 * @return: 成功    -   返回大于等于0
 *          失败    -   返回小于0
 * **/
plum_s32 plum_hal_dio_read_byte(plum_u32 id);

/**
 * @brief:  通过DIO写一个字节数据
 *
 * @param[in]:  id         -    端口plum ID
 * @param[in]:  value      -    待写数据值
 *
 * @return: 返回执行状态
 * **/
plum_s32 plum_hal_dio_write_byte(plum_u32 id, plum_u8 value);

/**
 * @brief:  通过DIO读取数据
 *
 * @param[in]:  id      -   端口plum ID
 * @param[in]:  addr    -   地址
 * @param[out]: rData   -   数据指针
 * @param[in]:  len     -   数据长度
 *
 * @return: 返回执行状态
 * **/
plum_s32 plum_hal_dio_read(plum_u32 id, plum_u32 addr, plum_u8 *rData,
                           plum_u32 len);

/**
 * @brief:  通过DIO写取数据
 *
 * @param[in]:  id      -   端口plum ID
 * @param[in]:  addr    -   地址
 * @param[in]:  wData   -   数据指针
 * @param[in]:  len     -   数据长度
 *
 * @return: 返回执行状态
 * **/
plum_s32 plum_hal_dio_write(plum_u32 id, plum_u32 addr, plum_u8 *wData,
                            plum_u32 len);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_HAL_DIO_H__ */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
